// pages/myOrder/myOrder.js
const QR = require('../../utils/weapp-qrcode.js')
const DB = wx.cloud.database()
Page({
  data: {
    motto: 'Hello World',
    qrcodeURL: "",
    codeText: "kshdfsk",
    myOrder: []
  },
  //绘制二维码
  drawImg() {
    var imgData = QR.drawImg(this.data.codeText, {
      typeNumber: 4,
      errorCorrectLevel: 'M',
      size: 500
    })
    this.setData({
      qrcodeURL: imgData
    })
  },
  
  showModal(e) {
    this.setData({
      modalName: e.currentTarget.dataset.target,
      codeText: e.currentTarget.dataset.id
    })
    this.drawImg();
  },
  hideModal(e) {
    this.setData({
      modalName: null
    })
  },
  onLoad() {
    wx.showLoading()
    wx.cloud.callFunction({
      name: 'getOrderList'
    }).then(res=>{
      console.log(res.result)
      this.setData({
        myOrder: res.result
      })
      wx.hideLoading()
    })
  }
})
